package com.liyy.platform.other.mytest;

import java.awt.*;
import java.awt.event.*;

public class TestFrame
{
	public static void main(String [] args){
		new Tframe().lunchframe();
	}
	
}

class Tframe extends Frame{
	TextField  t1,t2,t3;
	public void lunchframe(){
		Frame f=new Frame("my is first frame");
//		f.setResizable(false);//设置窗体是否可以调整的大小
		f.setBackground(Color.red);
		t1=new TextField(10);
		t2=new TextField(10);
		t3=new TextField(15);
		Button b1=new Button("=");
		Label l =new Label("+");
		Monitor m=new Monitor();
		m.get(this);
		b1.addActionListener(m);
		f.add(t1);
		f.add(l);
		f.add(t2);
		f.add(b1);
		f.add(t3);
		f.pack();
		f.setLayout(new FlowLayout());
		f.setVisible(true);

	}
	

}

class Monitor implements ActionListener{
	Tframe tf =null;
	public void get(Tframe tf){
		this.tf=tf;
	}
	
	public void actionPerformed(ActionEvent e) {
		int n1=Integer.parseInt(tf.t1.getText());
		int n2=Integer.parseInt(tf.t2.getText());
		tf.t3.setText(""+(n1+n2));
	}
	
}